/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.foxinline.servico;

import br.com.foxinline.modelo.Pais;
import java.util.List;
import javax.ejb.Stateless;

/**
 *
 * @author cadomeireles
 */

@Stateless
public class PaisServico extends ServicoGenerico<Pais> {

    public PaisServico() {
        super(Pais.class);
    }

    public List<Pais> autocompletar(String query){
        return buscarPeloNome(query);
    }

    public List<Pais> buscarPeloNome(String query){
        List<Pais> paises = getEntityManager().createQuery("select pais from " + Pais.class.getSimpleName() + " pais where lower(pais.nome) like '%" + query.toLowerCase().trim() + "%'").getResultList();
        return paises;
    }

}
